package com.pingbu.tijian.hospital.backapi.api;

import com.pingbu.common.bean.ResultBean;
import com.pingbu.tijian.hospital.backapi.bean.entity.UserPermission;
import com.pingbu.tijian.hospital.backapi.config.GlobalConst;
import com.pingbu.tijian.hospital.backapi.service.UserInfoService;
import com.pingbu.tijian.hospital.backapi.service.UserPermissionService;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/user_permission")
public class UserPermissionController {

    private static Logger logger = LoggerFactory.getLogger(UserPermissionController.class);

    @Autowired
    private UserPermissionService userPermissionService;

    /**
     * 获取系统中所有的权限
     * @return
     */
    @PostMapping(value = "/list_permissions")
    public ResultBean<List<String>> list_permissions(@RequestBody(required = false) Map<String,String> param) {

        // 1 获得参数中 userId
        String userId = param.get("noid");
        // 2 调用 userPermissionService 读取 该用户的所有权限列表
        return userPermissionService.listUserPermissionsByUserId(userId);
    }


}
